#ifndef SYSMSGHANDLER_H_INCLUDED
#define SYSMSGHANDLER_H_INCLUDED

static inline void handle_sys_msg( pSysMsg msg )
{
	SysMsgHandler hand = handlers[ msg->id ];
	if( hand != NULL )
	{
		hand( msg );
	}
}

static inline void handle_sys_msg_ack( pSysMsg msg )
{
	handle_sys_msg( msg );
	ack_msg( &( msg->mcb ) );
}

static inline void set_handler( uint8_t mid, SysMsgHandler hand )
{
	handlers[ mid ] = hand;
}
static inline void reset_handler( uint8_t mid )
{
	handlers[ mid ] = NULL;
}

static inline void clr_handler( uint8_t mid )
{
	set_handler( mid, NULL );
}

#define handleSysMsg(m) handle_sys_msg(m)

#endif /* SYSMSGHANDLER_H_INCLUDED */
